#pragma once
#define __IDxtCompositor_INTERFACE_DEFINED__
#define __IDxtAlphaSetter_INTERFACE_DEFINED__ 
#define __IDxtJpeg_INTERFACE_DEFINED__ 
#define __IDxtKey_INTERFACE_DEFINED__ 

#ifndef SAFE_RELEASE
#define SAFE_RELEASE( x ) if ( NULL != x ) { x->Release( ); x = NULL; }
#endif

//#include <qedit.h>
#include <dshow.h>
#include <conio.h>
#include <map>
#include <string>

#pragma comment(lib,"Strmiids.lib")
#pragma comment(lib,"Quartz.lib")

using namespace std;

typedef map<int,string>	device_list;

#include "audio_mgr.h"
#include "video_mgr.h"


class device_mgr
{
public:
	device_mgr(void);
	~device_mgr(void);
	
	bool init_direct_device();
	bool create_video_device(int id,int nWidth, int nHeight,int ct=1);
	bool start_video_capture();
	bool stop_video_capture();
	bool close_video_device();
	bool create_audio_input_device(int id);
	bool start_audio_capture();
	bool stop_audio_capture();
	bool close_audio_input_device();
	bool create_audio_output_device(int id);
	bool close_audio_output_device();
	
private:
	int				m_nWidth, m_nHeight;
	int				m_nSps,m_nBps;
	bool			m_bvRun;
	bool			m_baRun;
public:
	device_list		m_video_device_map;
	device_list		m_audio_input_device_map;
	device_list		m_audio_output_device_map;
	audio_input_mgr	*m_paudio_input_mgr;
	video_mgr		*m_pvideo_mgr;
private:
	CComPtr<IGraphBuilder>		m_pvideo_Graph;
	CComPtr<ISampleGrabber>		m_pvideo_SampleGrabber;
	CComPtr<IMediaControl>		m_pvideo_MediaControl;
	CComPtr<IMediaEvent>		m_pvideo_MediaEvent;
	CComPtr<IAMStreamConfig>	m_pvideo_StreamConfig;
	CComPtr<IBaseFilter>		m_pvideo_SampleGrabberFilter;
	CComPtr<IBaseFilter>		m_pvideo_DeviceFilter;
	CComPtr<IBaseFilter>		m_pvideo_NullFilter;
	CComPtr<IPin>				m_pvideo_GrabberInput;
	CComPtr<IPin>				m_pvideo_GrabberOutput;
	CComPtr<IPin>				m_pvideo_CameraOutput;
	CComPtr<IPin>				m_pvideo_NullInputPin;
	CComPtr<ISampleGrabberCB>	m_pvideo_GrabberCB;
	bool						m_bvideo_connect;


	CComPtr<IGraphBuilder>		m_paudio_Graph;
	CComPtr<ISampleGrabber>		m_paudio_SampleGrabber;
	CComPtr<IMediaControl>		m_paudio_MediaControl;
	CComPtr<IMediaEvent>		m_paudio_MediaEvent;
	CComPtr<IAMStreamConfig>	m_paudio_StreamConfig;
	CComPtr<IBaseFilter>		m_paudio_SampleGrabberFilter;
	CComPtr<IBaseFilter>		m_paudio_DeviceFilter;
	CComPtr<IBaseFilter>		m_paudio_NullFilter;
	CComPtr<IPin>				m_paudio_GrabberInput;
	CComPtr<IPin>				m_paudio_GrabberOutput;
	CComPtr<IPin>				m_paudio_CaptureOutput;
	CComPtr<IPin>				m_paudio_NullInputPin;
	CComPtr<ISampleGrabberCB>	m_paudio_GrabberCB;
	bool						m_baudio_connect;




};

